import QtQuick

Item {
    id: servoParameterBack_ParameterWindow
    width: 1760
    height: 935

    property real fontSize: Cpp_Language.CurrentLanguage === 1 ? 40 : Cpp_Language.CurrentLanguage === 2 ? 25 : Cpp_Language.CurrentLanguage === 3 ? 25 : 40

    Component.onCompleted: {
        Cpp_PLC.read_Servo_Parameters_Parameter_Setting_Hold();
    }

    A_NumberKeyboard{
        id: servoParameterKeyboard
        isDirectOverwrite: false
    }

    Column{         // 左侧列表
        anchors.left: servoParameterBack_ParameterWindow.left
        anchors.leftMargin: 100
        anchors.top: servoParameterBack_ParameterWindow.top
        anchors.topMargin: 20

        spacing: 10


        Item{
            width: 700
            height: 80

            Rectangle{
                width: 300
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                color: "transparent"
                // border.width: 1

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: qsTr("每圈脉冲数")
                }

            }

            A_NumberInput{      // 每圈脉冲数输入框
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 310
                inputWidth: 300
                inputHeight: 80
                keyboard: servoParameterKeyboard
                text: Cpp_PLC.Per_Rotation_Pulse

                onEditingFinished: function(value){
                    Cpp_PLC.write_into_PLC_32_Hold(200,value)
                }
            }

        }
        Item{
            width: 700
            height: 80

            Rectangle{
                width: 300
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                color: "transparent"
                // border.width: 1

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: qsTr("最大切割长度")
                }

            }

            A_NumberInput{      // 最大切割长度输入框
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 310
                inputWidth: 300
                inputHeight: 80
                keyboard: servoParameterKeyboard
                text: Cpp_PLC.Max_Cut_Length

                onEditingFinished: function(value){
                    Cpp_PLC.write_into_PLC_32_Hold(216,value)
                }
            }

        }
        Item{
            width: 700
            height: 80

            Rectangle{
                width: 300
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                color: "transparent"
                // border.width: 1

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: qsTr("找零点高速")
                }

            }

            A_NumberInput{      // 找零点高速输入框
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 310
                inputWidth: 300
                inputHeight: 80
                keyboard: servoParameterKeyboard
                text: Cpp_PLC.Find_Zero_High_Speed

                onEditingFinished: function(value){
                    Cpp_PLC.write_into_PLC_32_Hold(220,value)
                }
            }

        }
        Item{
            width: 700
            height: 80

            Rectangle{
                width: 300
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                color: "transparent"
                // border.width: 1

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: qsTr("加减速时间")
                }

            }

            A_NumberInput{      //加减速时间输入框
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 310
                inputWidth: 300
                inputHeight: 80
                keyboard: servoParameterKeyboard
                text: Cpp_PLC.Acc_Dec_Time

                onEditingFinished: function(value){
                    Cpp_PLC.write_into_PLC_16_Hold(208,value)
                }
            }

        }
        Item{
            width: 700
            height: 80

            Rectangle{
                width: 300
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                color: "transparent"
                // border.width: 1

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: qsTr("刹车打开时间")
                }

            }

            A_NumberInput{      // 刹车打开时间输入框
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 310
                inputWidth: 300
                inputHeight: 80
                keyboard: servoParameterKeyboard
                text: Cpp_PLC.Brake_Open_Time

                onEditingFinished: function(value){
                    Cpp_PLC.write_into_PLC_32_Hold(1278,value)
                }
            }

        }
        Item{
            width: 700
            height: 80

            Rectangle{
                width: 300
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                color: "transparent"
                // border.width: 1

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: qsTr("长按 2s 设零点")
                }

            }

            A_Button{      // 设置机械零点按钮
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 310
                buttonWidth: 300
                buttonHeight: 80
                contentText_Data: qsTr("设置机械零点")

                onButtonPressed: Cpp_PLC.write_into_PLC_Coils(26,true)
                onButtonReleased: Cpp_PLC.write_into_PLC_Coils(26,false)
                onButtonPressedAndHold: Cpp_PLC.write_into_PLC_Coils(147,true)
            }

        }
        // Item{
        //     width: 700
        //     height: 80

        //     Rectangle{
        //         width: 300
        //         height: 80
        //         anchors.verticalCenter: parent.verticalCenter
        //         anchors.left: parent.left
        //         color: "transparent"
        //         // border.width: 1

        //         Text{
        //             anchors.centerIn: parent
        //             font.pixelSize: fontSize
        //             font.bold: true
        //             text: qsTr("左拉料延迟")
        //         }

        //     }

        //     A_NumberInput{      // 左拉料延迟输入框
        //         anchors.verticalCenter: parent.verticalCenter
        //         anchors.left: parent.left
        //         anchors.leftMargin: 310
        //         inputWidth: 300
        //         inputHeight: 80
        //         keyboard: servoParameterKeyboard

        //         onEditingFinished: function(value){
        //             console.log(value)
        //         }
        //     }

        // }
        // Item{
        //     width: 700
        //     height: 80

        //     Rectangle{
        //         width: 300
        //         height: 80
        //         anchors.verticalCenter: parent.verticalCenter
        //         anchors.left: parent.left
        //         color: "transparent"
        //         // border.width: 1

        //         Text{
        //             anchors.centerIn: parent
        //             font.pixelSize: fontSize
        //             font.bold: true
        //             text: qsTr("左右吹气时间")
        //         }

        //     }

        //     A_NumberInput{      // 左右吹气时间输入框
        //         anchors.verticalCenter: parent.verticalCenter
        //         anchors.left: parent.left
        //         anchors.leftMargin: 310
        //         inputWidth: 300
        //         inputHeight: 80
        //         keyboard: servoParameterKeyboard

        //         onEditingFinished: function(value){
        //             console.log(value)
        //         }
        //     }

        // }

    }



    Column{         // 右侧列表
        anchors.right: servoParameterBack_ParameterWindow.right
        anchors.rightMargin: 100
        anchors.top: servoParameterBack_ParameterWindow.top
        anchors.topMargin: 20

        spacing: 10


        Item{
            width: 700
            height: 80

            Rectangle{
                width: 300
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                color: "transparent"
                // border.width: 1

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: qsTr("每圈位移量")
                }

            }

            A_NumberInput{      // 每圈位移量输入框
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 310
                inputWidth: 300
                inputHeight: 80
                keyboard: servoParameterKeyboard
                text: Cpp_PLC.Per_Rotation_Distance

                onEditingFinished: function(value){
                    Cpp_PLC.write_into_PLC_32_Hold(202,value)
                }
            }

        }
        Item{
            width: 700
            height: 80

            Rectangle{
                width: 300
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                color: "transparent"
                // border.width: 1

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: qsTr("反向软限位")
                }

            }

            A_NumberInput{      // 反向软限位输入框
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 310
                inputWidth: 300
                inputHeight: 80
                keyboard: servoParameterKeyboard
                text: Cpp_PLC.Reverse_Soft_Limit

                onEditingFinished: function(value){
                    Cpp_PLC.write_into_PLC_32_Hold(218,value)
                }
            }

        }
        Item{
            width: 700
            height: 80

            Rectangle{
                width: 300
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                color: "transparent"
                // border.width: 1

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: qsTr("找零点低速")
                }

            }

            A_NumberInput{      //找零点低速输入框
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 310
                inputWidth: 300
                inputHeight: 80
                keyboard: servoParameterKeyboard
                text: Cpp_PLC.Find_Zero_Low_Speed

                onEditingFinished: function(value){
                    Cpp_PLC.write_into_PLC_32_Hold(222,value)
                }
            }

        }
        Item{
            width: 700
            height: 80    

        }
        Item{
            width: 700
            height: 80

            Rectangle{
                width: 300
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                color: "transparent"
                // border.width: 1

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: qsTr("刹车关闭延时")
                }

            }

            A_NumberInput{      //刹车关闭延时输入框
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 310
                inputWidth: 300
                inputHeight: 80
                keyboard: servoParameterKeyboard
                text: Cpp_PLC.Brake_Close_Delay

                onEditingFinished: function(value){
                    Cpp_PLC.write_into_PLC_16_Hold(602,value)
                }
            }

        }
        Item{
            width: 700
            height: 80

            Rectangle{
                width: 300
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                border.width: 3
                radius: 5
                border.color: "white"
                color: "black"

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    color: "white"
                    text: Cpp_PLC.Core_Number
                }

            }

            A_Button{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 310
                buttonWidth: 300
                buttonHeight: 80
                contentText_Data: qsTr("读取电机位置")                

                onButtonPressed: Cpp_PLC.write_into_PLC_Coils(53,true)
                onButtonReleased: Cpp_PLC.write_into_PLC_Coils(53,false)

            }

        }



    }

}
